package pl.edu.agh.sius.model;

import java.io.File;

import javax.faces.model.SelectItem;

import pl.edu.agh.sius.controller.InputFileController;

public class WasteTransportRequestBB implements ConcernBB {

	protected final WasteTransportRequest wtr = new WasteTransportRequest();
	
	public String getAddress() {
		return wtr.getAddress();
	}

	public String getFinancialGuaranteesDocURL() {
		return wtr.getFinancialGuaranteesDocURL();
	}

	public String getFirstName() {
		return wtr.getFirstName();
	}

	public String getPesel() {
		return wtr.getPesel();
	}

	public String getSurname() {
		return wtr.getSurname();
	}

	public String getWasteTransportPermissionPetitionDocURL() {
		return wtr.getWasteTransportPermissionPetitionDocURL();
	}

	public void setAddress(String address) {
		wtr.setAddress(address);
	}

	public void setFinancialGuaranteesDocURL(String financialGuaranteesDocURL) {
		wtr.setFinancialGuaranteesDocURL(financialGuaranteesDocURL);
	}

	public void setFirstName(String firstName) {
		wtr.setFirstName(firstName);
	}

	public void setPesel(String pesel) {
		wtr.setPesel(pesel);
	}

	public void setSurname(String surname) {
		wtr.setSurname(surname);
	}

	public void setWasteTransportPermissionPetitionDocURL(
			String wasteTransportPermissionPetitionDocURL) {
		wtr
				.setWasteTransportPermissionPetitionDocURL(wasteTransportPermissionPetitionDocURL);
	}

	public static final String WASTE_TRANSPORT_PERMISSION_PETITION = "Zgoda na transport odpadów",
			FINANCIAL_GRUARANEES = "Poświadczenie majątkowe";

	private static String[] formalDocumentNames = new String[] {
			WASTE_TRANSPORT_PERMISSION_PETITION, FINANCIAL_GRUARANEES };

	public SelectItem[] getFormalDocumentsNames() {
		SelectItem[] items = new SelectItem[formalDocumentNames.length];
		for (int i = 0; i < formalDocumentNames.length; ++i) {
			items[i] = new SelectItem(formalDocumentNames[i]);
		}
		return items;
	}

	public boolean areAttachementsValid(InputFileController ifc) {
		if (ifc.getFileList().size() != formalDocumentNames.length) {
			return false;
		}
		for (InputFileData ifd1 : ifc.getFileList()) {
			if (ifd1.getFileFormalName() == null) {
				return false;
			}
			for (InputFileData ifd2 : ifc.getFileList()) {
				if (!ifd1.equals(ifd2)) {
					if (ifd1.getFileFormalName().equals(
							ifd2.getFileFormalName())) {
						return false;
					}
				}
			}
		}
		return true;
	}

	private File financialGuaranteesFile, wasteTransportPermissionPetitionFile;

	public File getFinancialGuaranteesFile() {
		return financialGuaranteesFile;
	}

	public void setFinancialGuaranteesFile(File financialGuaranteesFile) {
		this.financialGuaranteesFile = financialGuaranteesFile;
	}

	public File getWasteTransportPermissionPetitionFile() {
		return wasteTransportPermissionPetitionFile;
	}

	public void setWasteTransportPermissionPetitionFile(
			File wasteTransportPermissionPetitionFile) {
		this.wasteTransportPermissionPetitionFile = wasteTransportPermissionPetitionFile;
	}

	private boolean agreement = false;

	public boolean isAgreement() {
		return agreement;
	}

	public void setAgreement(boolean agreement) {
		this.agreement = agreement;
	}


}
